function [varargout] = print_block(arg)

names=fieldnames(arg);
nfield = length(names);
s_field = strmatch('start', names);
e_field = strmatch('end', names);
if(isempty(s_field) | isempty(e_field))
   QueMessage(sprintf('structure %s lacks start or end field', arg.title));
   err = 1;
   return;
end

nm = size(char(names));
ml = nm(2) + 2;
list = [];

fmt1 = sprintf('%%%ds : ', ml);
list = cellcat(list, sprintf('\n..................................\n'));
for i = 1:length(names)
   if(i < s_field | i > e_field)
      v = eval(['arg.' char(names(i))]);
      list = cellcat(list, sprintf(fmt1, char(names(i))));
      if(isempty(strmatch(char(names(i)), {'method_code', 'waveform', 'tbase', 'fhandles'}, 'exact')))
         if(isempty(v))
            list = cellcat(list, sprintf( '/e/ [] '));
         elseif(isnumeric(v))
            list = cellcat(list, sprintf( '/n/ %g ', v));
         elseif (ischar(v))
            list = cellcat(list, sprintf( '/s/ %s ', v));
         end;
      else
         if(isempty(v))
            list = cellcat(list, sprintf( '/e/ []'));
         elseif(ischar(v))
            list = cellcat(list, sprintf( '/s/ (data)'));
         elseif(isnumeric(v))
            list = cellcat(list, sprintf( '/n/ (data)'));
         elseif(isstruct(v))
            list = cellcat(list, sprintf( '/S/ (structure)'));
            a=fieldnames(v);
            list = cellcat(list, sprintf( ' %s', a)); 
         elseif(iscell(v))
            list = cellcat(list, sprintf( '/c/ (cell {%d})', length(v)));
            
         end;
      end;
   end;
   if(i == s_field)
      list = cellcat(list, sprintf( '*------------------------------*'));
   end;
   if(i == e_field)
      list = cellcat(list, sprintf( '*------------------------------*'));
   end;
   if(i > s_field & i < e_field)
      v = eval(['arg.' char(names(i)) '.v']);
      list = cellcat(list, sprintf( fmt1, char(names(i))));
      if(isempty(strmatch(char(names(i)), strvcat('method_code', 'waveform', 'tbase'), 'exact')))
         if(isempty(v))
            list = cellcat(list, sprintf( '/e/ [] '));
         elseif(isnumeric(v))
            list = cellcat(list, sprintf( '/n/ %g ', v));
         elseif (ischar(v))
            list = cellcat(list, sprintf( '/s/ %s ', v));
         end;
      else
         if(isempty(v))
            list = cellcat(list, sprintf( '/e/ []'));
         elseif(ischar(v))
            list = cellcat(list, sprintf( '/s/ (data)'));
         elseif(isnumeric(v))
            list = cellcat(list, sprintf( '/n/ (data)'));
         elseif(isstruct(v))
            list = cellcat(list, sprintf( '/S/ (structure)'));
            a=fieldnames(v);
            list = cellcat(list, sprintf( ' %s', a)); 
         elseif(iscell(v))
            list = cellcat(list, sprintf( '/c/ (cell {%d})', length(v)));
         end;
         
      end;
   end;
   list = cellcat(list, sprintf('\n'));
end;

if(nargout == 0) % display data on terminal
    for i = 1:length(list)
        fprintf(1, '%s', char(list{i}));
    end;
else
    so = [];
    for i = 1:length(list)
        so = [so char(list{i})];
    end;
    varargout{1} = so; % return as a single string suitable for writing to disk.
end;

return;

function [o] = cellcat(in, string)
o = in;
p = length(in) + 1;
o{p} = string;
return;

